<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"always","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="STL cout的格式化收集整理如下, 以便查阅. 综述cout是STL库提供的一个iostream实例，拥有ios_base基类的全部函数和成员数据.进行格式化操作可以直接利用setf&#x2F;unsetf函数和flags函数.  cout维护一个当前的格式状态, setf&#x2F;unsetf函数是在当前的格式状态上追加或删除指定的格式, flags则是将当前格式状态全部替换为指定的格式。  cout为这个函">
<meta property="og:type" content="article">
<meta property="og:title" content="cout的格式化">
<meta property="og:url" content="http://yoursite.com/2019/10/04/cout%E7%9A%84%E6%A0%BC%E5%BC%8F%E5%8C%96/index.html">
<meta property="og:site_name" content="LazyStones">
<meta property="og:description" content="STL cout的格式化收集整理如下, 以便查阅. 综述cout是STL库提供的一个iostream实例，拥有ios_base基类的全部函数和成员数据.进行格式化操作可以直接利用setf&#x2F;unsetf函数和flags函数.  cout维护一个当前的格式状态, setf&#x2F;unsetf函数是在当前的格式状态上追加或删除指定的格式, flags则是将当前格式状态全部替换为指定的格式。  cout为这个函">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2019-10-04T12:24:14.000Z">
<meta property="article:modified_time" content="2020-06-06T17:30:28.022Z">
<meta property="article:author" content="Leiz">
<meta property="article:tag" content="c++">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://yoursite.com/2019/10/04/cout%E7%9A%84%E6%A0%BC%E5%BC%8F%E5%8C%96/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>cout的格式化 | LazyStones</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">LazyStones</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/10/04/cout%E7%9A%84%E6%A0%BC%E5%BC%8F%E5%8C%96/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="Leiz">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="LazyStones">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          cout的格式化
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-10-04 20:24:14" itemprop="dateCreated datePublished" datetime="2019-10-04T20:24:14+08:00">2019-10-04</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-06-07 01:30:28" itemprop="dateModified" datetime="2020-06-07T01:30:28+08:00">2020-06-07</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/c/" itemprop="url" rel="index"><span itemprop="name">c++</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>STL cout的格式化收集整理如下, 以便查阅.</p>
<h2 id="综述"><a href="#综述" class="headerlink" title="综述"></a>综述</h2><p>cout是STL库提供的一个iostream实例，拥有ios_base基类的全部函数和成员数据.<br>进行格式化操作可以直接利用setf/unsetf函数和flags函数.</p>
<blockquote>
<p>cout维护一个当前的格式状态, setf/unsetf函数是在当前的格式状态上追加或删除指定的格式, flags则是将当前格式状态全部替换为指定的格式。</p>
</blockquote>
<p>cout为这个函数提供了如下参数（可选格式）：</p>
<ul>
<li>ios::dec            以10进制表示整数</li>
<li>ios::hex            以16进制表示整数</li>
<li>ios::oct            以8进制表示整数</li>
<li>ios::showbase       为整数添加一个表示其进制的前缀</li>
<li>ios::internal       在符号位和数值的中间插入需要数量的填充字符以使串两端对齐</li>
<li>ios::left           在串的末尾插入填充字符以使串居左对齐</li>
<li>ios::right          在串的前面插入填充字符以使串居右对齐</li>
<li>ios::boolalpha      将bool类型的值以true或flase表示，而不是1或0</li>
<li>ios::fixed          将符点数按照普通定点格式处理（非科学计数法）</li>
<li>ios::scientific     将符点数按照科学计数法处理（带指数域）</li>
<li>ios::showpoint      在浮点数表示的小数中强制插入小数点（默认情况是浮点数表示的整数不显示- 小数点）</li>
<li>ios::showpos        强制在正数前添加+号</li>
<li>ios::skipws         忽略前导的空格（主要用于输入流，如cin）</li>
<li>ios::unitbuf        在插入（每次输出）操作后清空缓存</li>
<li>ios::uppercase      强制大写字母</li>
</ul>
<a id="more"></a>

<p>以上每一种格式都占用独立的一位，因此可以用“|”（位或）运算符组合使用。<br>调用setf/unsetf或flags设置格式一般按如下方式进行：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cout</span>.setf(ios::right | ios::hex);           <span class="comment">//设置16进制右对齐</span></span><br><span class="line"><span class="built_in">cout</span>.setf(ios::right, ios::adjustfield);    <span class="comment">//取消其它对齐，设置为右对齐</span></span><br></pre></td></tr></table></figure>

<p>setf可接受一个或两个参数，一个参数的版本为设置指定的格式，后一个参数指定了删除的格式。</p>
<p>三个已定义的组合格式为：</p>
<ul>
<li>ios::adjustfield    对齐格式的组合位</li>
<li>ios::basefield      进制的组合位</li>
<li>ios::floatfield     浮点表示方式的组合位</li>
</ul>
<p>设置格式之后，下面所有使用cout进行的输出都会按照指定的格式状态执行。<br>但是如果在一次输出过程中需要混杂多种格式，使用cout的成员函数来处理就显得很不方便了。</p>
<p>STL另提供了一套<em>iomanip</em>库可以满足这种使用方式。<em>iomanip</em>库中将每一种格式的设置和删除都进行了函数级的同名封装，比如fixed函数，就可以将一个ostream的对象作为参数，在内部调用setf函数对其设置ios::fixed格式后再返回原对象。</p>
<p>此外<em>iomanip</em>还提供了setiosflags、setbase、setfill、setw、setprecision等方便的格式控制函数，下文会逐一进行介绍。大多数示例代码都会使用到<em>iomanip</em>，因此默认包含的头文件均为：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br></pre></td></tr></table></figure>

<h2 id="缩进"><a href="#缩进" class="headerlink" title="缩进"></a>缩进</h2><p>将输出内容按指定的宽度对齐，需要用到ios::right、ios::left、ios::internal和iomanip里的setw。</p>
<p>其中 setw用于指定要输出内容的对齐宽度。以下两段代码的结果完全相同，前面是一个浮点数-456.98，后面紧跟着一个字符串“The End”以及换行符“endl”。</p>
<p><em>代码一：</em></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span>.flags(ios::left); <span class="comment">//左对齐</span></span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setw(<span class="number">10</span>) &lt;&lt; <span class="number">-456.98</span> &lt;&lt; <span class="string">"The End"</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span>.flags(ios::internal); <span class="comment">//两端对齐</span></span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setw(<span class="number">10</span>) &lt;&lt; <span class="number">-456.98</span> &lt;&lt; <span class="string">"The End"</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span>.flags(ios::right); <span class="comment">//右对齐</span></span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setw(<span class="number">10</span>) &lt;&lt; <span class="number">-456.98</span> &lt;&lt; <span class="string">"The End"</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><em>代码二：</em></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; left &lt;&lt; setw(<span class="number">10</span>) &lt;&lt; <span class="number">-456.98</span> &lt;&lt; <span class="string">"The End"</span> &lt;&lt; <span class="built_in">endl</span>; <span class="comment">//左对齐</span></span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; internal &lt;&lt; setw(<span class="number">10</span>) &lt;&lt; <span class="number">-456.98</span> &lt;&lt; <span class="string">"The End"</span> &lt;&lt; <span class="built_in">endl</span>; <span class="comment">//两端对齐</span></span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; right &lt;&lt; setw(<span class="number">10</span>) &lt;&lt; <span class="number">-456.98</span> &lt;&lt; <span class="string">"The End"</span> &lt;&lt; <span class="built_in">endl</span>; <span class="comment">//右对齐</span></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">-456.98 The End</span><br><span class="line">- 456.98The End</span><br><span class="line">-456.98The End</span><br></pre></td></tr></table></figure>

<p>这里要额外说明的一点是，setw函数会用当前的填充字符控制对齐位置，默认的填充字符是空格。</p>
<p>可以通过<code>&lt;iomanip&gt;</code>的setfill来设置填充字符，比如下面的代码用字符“0”作为填充字符：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setfill(<span class="string">'0'</span>) &lt;&lt; setw(<span class="number">10</span>) &lt;&lt; <span class="number">45698</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果： 0000045698</p>
<h2 id="整数"><a href="#整数" class="headerlink" title="整数"></a>整数</h2><p>输出整数的格式有按不同进制数出：ios::hex（16进制）, ios::dec（10进制）, ios::oct（ 8进制）, 也可强制其输出符号（正数也加上“+”号前缀），对于16进制的输出还可配合<strong>ios::uppercase</strong>使所有字母以大写表示。</p>
<p>代码示例如下：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span>.setf(ios::showpos | ios::uppercase);</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; hex &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; <span class="number">12</span> &lt;&lt; setw(<span class="number">12</span>) &lt;&lt; <span class="number">-12</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; dec &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; <span class="number">12</span> &lt;&lt; setw(<span class="number">12</span>) &lt;&lt; <span class="number">-12</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; oct &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; <span class="number">12</span> &lt;&lt; setw(<span class="number">12</span>) &lt;&lt; <span class="number">-12</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span>.unsetf(ios::showpos | ios::uppercase);</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; hex &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; <span class="number">12</span> &lt;&lt; setw(<span class="number">12</span>) &lt;&lt; <span class="number">-12</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; dec &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; <span class="number">12</span> &lt;&lt; setw(<span class="number">12</span>) &lt;&lt; <span class="number">-12</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; oct &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; <span class="number">12</span> &lt;&lt; setw(<span class="number">12</span>) &lt;&lt; <span class="number">-12</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果： C FFFFFFF4 +12 -12 14 37777777764 c fffffff4 12 -12 14 37777777764</p>
<p>利用<code>&lt;iomanip&gt;</code>的setbase函数同样可以设置整数的三种进制，参数分别为8、10和16，但使用起来比上面的方法还更复杂一些，除非是特殊的代码规范要求（有些规范要求避免将常量直接作为表达式），一般不建议使用setbase。</p>
<p>此外，还可以利用ios::showbase来为整数的前面加一个表示进制的前缀，代码如下：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; showbase &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; hex &lt;&lt; <span class="number">32</span> &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; oct &lt;&lt; <span class="number">32</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; noshowbase &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; hex &lt;&lt; <span class="number">32</span> &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; oct &lt;&lt; <span class="number">32</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果： 0x20 040 20 40</p>
<p>上面代码中的showbase/noshobase也可以用cout的setf来代替，其结果是完全相同的：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span>.setf(ios::showbase);</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; hex &lt;&lt; <span class="number">32</span> &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; oct &lt;&lt; <span class="number">32</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span>.unsetf(ios::showbase);</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; hex &lt;&lt; <span class="number">32</span> &lt;&lt; setw(<span class="number">4</span>) &lt;&lt; oct &lt;&lt; <span class="number">32</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="小数"><a href="#小数" class="headerlink" title="小数"></a>小数</h2><p>小数可分为两种格式类型，一种是定点表示“ios::fixed”（不带指数域），另一种是科学计数法表示“ios::scientific”（带指数域）。与<code>&lt;iomanip&gt;</code>的setprecision配合使用，可以表示指定小数点后面的保留位数（四舍五入）。</p>
<p>示例代码如下：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span>.setf(ios::fixed);</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">0</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">1</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">2</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">3</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span>.setf(ios::scientific, ios::floatfield);</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">0</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">1</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">2</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; setprecision(<span class="number">3</span>) &lt;&lt; <span class="number">12.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果： 12 12.1 12.05 12.050 1.205000e+001 1.2e+001 1.21e+001 1.205e+001</p>
<p>需要注意的是，有时会因为机器的精度问题导致四舍五入的结果不正确。这种问题一般需要手动修正，见如下代码示例：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; fixed &lt;&lt; setprecision(<span class="number">1</span>) &lt;&lt; <span class="number">2.05</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; fixed &lt;&lt; setprecision(<span class="number">1</span>) &lt;&lt; <span class="number">2.05</span> + <span class="number">1e-8</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果： 2.0 2.1</p>
<h2 id="字符串"><a href="#字符串" class="headerlink" title="字符串"></a>字符串</h2><p>字符串的输出处理主要是对齐，这一点在第二部分已经介绍过了，下面主要介绍字符串的输入方法。</p>
<p>为了方便起见，我们使用<code>&lt;string&gt;</code>库。在输入字符串时，可以利用<code>&lt;string&gt;</code>库提供的getline函数读取整行数据。</p>
<p>getline函数有两个版本:</p>
<p>第一个版本有两个参数，第一个参数指定输入流（比如cin），第二个参数指定一个string对象。getline会读取屏幕上输入的字符，直到遇到换行符“\n”为止；</p>
<p>第二个版本有三个参数，前两个与第一个版本相同，第三个参数为指定的结束字符。</p>
<p>注意，getline不会读入默认或指定的结束字符，但在调用之后读取的位置已经跳过结束字符。调用示例代码如下：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">string</span> str1, str2;</span><br><span class="line">    getline(<span class="built_in">cin</span>, str1);</span><br><span class="line">    <span class="built_in">cin</span> &gt;&gt; str2;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; str1 &lt;&lt; <span class="built_in">endl</span> &lt;&lt; str2 &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>输入： abc abc</p>
<p>结果： abc abc</p>
<h2 id="缓冲区"><a href="#缓冲区" class="headerlink" title="缓冲区"></a>缓冲区</h2><p>由于调用系统函数在屏幕上逐个显示字符是很慢的，因此cin/cout为了加快速度使用缓冲区技术，粗略的讲就是暂时不输出指定的字符，而是存放在缓冲区中，在合适的时机一次性输出到屏幕上。</p>
<p>如果单纯使用C++的输入/输出流来操作字符是不存在同步的问题的，但是如果要和C标准库的stdio库函数混合使用就必须要小心的处理缓冲区了。</p>
<p>如果要与scanf和printf联合使用，务必在调用cout前加上cout.sync_with_stdio()，设置与stdio同步，否则输出的数据顺序会发生混乱。</p>
<p>flush和endl都会将当前缓冲区中的内容立即写入到屏幕上，而unitbuf/nounitbuf可以禁止或启用缓冲区。</p>
<p>示例代码如下：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; <span class="number">123</span> &lt;&lt; flush &lt;&lt; <span class="number">456</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; unitbuf &lt;&lt; <span class="number">123</span> &lt;&lt; nounitbuf &lt;&lt; <span class="number">456</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果： 123456 123456</p>
<h2 id="综合使用"><a href="#综合使用" class="headerlink" title="综合使用"></a>综合使用</h2><p>示例代码：</p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iomanip&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;string&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">COMMODITY</span> &#123;</span> <span class="built_in">string</span> Name; <span class="keyword">int</span> Id; <span class="keyword">int</span> Cnt; <span class="keyword">double</span> Price; &#125;;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">(<span class="keyword">void</span>)</span> </span>&#123;</span><br><span class="line">    COMMODITY cmd[] = &#123;</span><br><span class="line">        &#123;<span class="string">"Fruit"</span>, <span class="number">0x101</span>, <span class="number">50</span>, <span class="number">5.268</span>&#125;,</span><br><span class="line">        &#123;<span class="string">"Juice"</span>, <span class="number">0x102</span>, <span class="number">20</span>, <span class="number">8.729</span>&#125;,</span><br><span class="line">        &#123;<span class="string">"Meat"</span>, <span class="number">0x104</span>, <span class="number">30</span>, <span class="number">10.133</span>&#125;,</span><br><span class="line">    &#125;;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; left &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; <span class="string">"NAME"</span> &lt;&lt; right &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; <span class="string">"ID"</span>;</span><br><span class="line">    <span class="built_in">cout</span> &lt;&lt; right &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; <span class="string">"COUNT"</span> &lt;&lt; right &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; <span class="string">"PRICE"</span> &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; <span class="keyword">sizeof</span>(cmd) / <span class="keyword">sizeof</span>(cmd[<span class="number">0</span>]); ++i) &#123;</span><br><span class="line">        <span class="built_in">cout</span> &lt;&lt; left &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; cmd[i].Name;</span><br><span class="line">        <span class="built_in">cout</span> &lt;&lt; right &lt;&lt; hex &lt;&lt; showbase &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; cmd[i].Id;</span><br><span class="line">        <span class="built_in">cout</span> &lt;&lt; dec &lt;&lt; noshowbase &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; cmd[i].Cnt;</span><br><span class="line">        <span class="built_in">cout</span> &lt;&lt; fixed &lt;&lt; setw(<span class="number">8</span>) &lt;&lt; setprecision(<span class="number">2</span>) &lt;&lt; cmd[i].Price &lt;&lt; <span class="built_in">endl</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>结果：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">NAME          ID   COUNT   PRICE</span><br><span class="line">Fruit      0x101      50    5.27</span><br><span class="line">Juice      0x102      20    8.73</span><br><span class="line">Meat       0x104      30   10.13</span><br></pre></td></tr></table></figure>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/c/" rel="tag"># c++</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2019/10/04/%E4%BA%8C%E5%8F%89%E6%A0%91%E5%89%8D%E4%B8%AD%E5%90%8E%E5%BA%8F%E9%81%8D%E5%8E%86/" rel="prev" title="二叉树前中后序遍历">
      <i class="fa fa-chevron-left"></i> 二叉树前中后序遍历
    </a></div>
      <div class="post-nav-item">
    <a href="/2019/10/04/Flask%E4%BD%BF%E7%94%A8https/" rel="next" title="Flask使用https">
      Flask使用https <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#综述"><span class="nav-number">1.</span> <span class="nav-text">综述</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#缩进"><span class="nav-number">2.</span> <span class="nav-text">缩进</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#整数"><span class="nav-number">3.</span> <span class="nav-text">整数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#小数"><span class="nav-number">4.</span> <span class="nav-text">小数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#字符串"><span class="nav-number">5.</span> <span class="nav-text">字符串</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#缓冲区"><span class="nav-number">6.</span> <span class="nav-text">缓冲区</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#综合使用"><span class="nav-number">7.</span> <span class="nav-text">综合使用</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">Leiz</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">32</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">15</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/leiz2192" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;leiz2192" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:zhanglei2192@hotmail.com" title="E-Mail → mailto:zhanglei2192@hotmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/u/1301301533/home?leftnav=1" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;u&#x2F;1301301533&#x2F;home?leftnav&#x3D;1" rel="noopener" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Leiz</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

</body>
</html>
